/*
 * @Author: your name
 * @Date: 2022-02-03 14:55:55
 * @LastEditTime: 2022-02-03 15:01:20
 * @LastEditors: Please set LastEditors
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: \vue3-vite-tsx\src\components\loading\index.ts
 */
import { createApp, reactive, ComponentPublicInstance } from 'vue'

import loading from './src/loading'

const options = reactive({
  show: false
})

let $vm: ComponentPublicInstance | null = null

if (!$vm) {
  const wrapper = document.createElement('div')
  document.body.appendChild(wrapper)
  $vm = createApp(loading, { options }).mount(wrapper)
}

// 控制状态
export const Loading = {
  show() {
    options.show = true
  },
  hide() {
    options.show = false
  }
}
